﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace Sprout.Repository.Template.XParseEngine
{
    internal class IsLessEqualDeSerializer : BaseDeSerializer, IDeSerializer
    {
        /// <summary>
        /// 验证节点
        /// </summary>
        /// <param name="node">节点</param>
        /// <param name="prepend">拼接字符串</param>
        /// <param name="property">属性</param>
        /// <param name="value">参数值</param>
        /// <param name="compareValue">节点判断值</param>
        /// <returns>是否成功</returns>
        public override bool ValidateProperty(XmlNode node, string prepend, string property, string value, string compareValue)
        {
            decimal convertCoupareValue = 0;
            decimal convertValue = 0;
            if (decimal.TryParse(compareValue, out convertCoupareValue) == false)
            {
                return false;
            }
            if (decimal.TryParse(value, out convertValue) == false)
            {
                return false;
            }
            if (convertValue <= convertCoupareValue)
            {
                return true;
            }
            return false;
        }
    }
}
